package dieci.system;

import dieci.database.PersistentObject;
import dieci.utils.Redondeo;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

/**
 *
 * @author DuckSys
 */
public class Sale implements PersistentObject
{

    private long saleId;
    private Date saleDate;
    private Client client;
    private Set<SaleDetails> details = new HashSet();
    private double totalSaleAmount;
    private double discount;
    private String discountType;
    private boolean charged;
    private boolean delivered;

    
    public Sale(Client client, Date saleDate)
    {
        this.client = client;
        this.saleDate = saleDate;
    }

    public Sale(Client client, Date saleDate, Set<SaleDetails> details, 
            double disc, String discType, double totalAmount, boolean charged, boolean delivered)
    {
        this(client, saleDate);
        this.details = details;
        this.discount = Redondeo.Redondear(disc, 2);
        this.totalSaleAmount = Redondeo.Redondear(totalAmount,2);
        this.charged = charged;
        this.delivered = delivered;
        this.discountType = discType;
    }

    public Sale(long saleId, Client client, Date saleDate, Set<SaleDetails> details, 
            double disc, String discType, double totalAmount, boolean charged, boolean delivered)
    {
        this(client, saleDate, details, disc, discType, totalAmount, charged, delivered);
        this.saleId = saleId;
    }
    
    /**
     * Get the value of saleId
     *
     * @return the value of saleId
     */
    public long getSaleId()
    {
        return saleId;
    }

    /**
     * Set the value of saleId
     *
     * @param saleId new value of saleId
     */
    public void setSaleId(long saleId)
    {
        this.saleId = saleId;
    }

        /**
     * Get the value of charged
     *
     * @return the value of charged
     */
    public boolean isCharged()
    {
        return charged;
    }

    /**
     * Set the value of charged
     *
     * @param charged new value of charged
     */
    public void setCharged(boolean charged)
    {
        this.charged = charged;
    }

    
    /**
     * Get the value of totalSaleAmount
     *
     * @return the value of totalSaleAmount
     */
    public double getTotalSaleAmount()
    {
        return totalSaleAmount;
    }

    /**
     * Set the value of totalSaleAmount
     *
     * @param totalSaleAmount new value of totalSaleAmount
     */
    public void setTotalSaleAmount(double totalSaleAmount)
    {
        this.totalSaleAmount = Redondeo.Redondear(totalSaleAmount, 2);
    }

    /**
     * Get the value of details
     *
     * @return the value of details
     */
    public Set<SaleDetails> getDetails()
    {
        return details;
    }

    /**
     * Set the value of details
     *
     * @param details new value of details
     */
    public void setDetails(Set<SaleDetails> details)
    {
        this.details = details;
    }

    /**
     * Get the value of client
     *
     * @return the value of client
     */
    public Client getClient()
    {
        return client;
    }

    /**
     * Set the value of client
     *
     * @param client new value of client
     */
    public void setClient(Client client)
    {
        this.client = client;
    }

    /**
     * Get the value of saleDate
     *
     * @return the value of saleDate
     */
    public Date getSaleDate()
    {
        return saleDate;
    }

    /**
     * Set the value of saleDate
     *
     * @param saleDate new value of saleDate
     */
    public void setSaleDate(Date saleDate)
    {
        this.saleDate = saleDate;
    }

    /**
     * Get the value of discount
     *
     * @return the value of discount
     */
    public double getDiscount()
    {
        return discount;
    }

    /**
     * Set the value of discount
     *
     * @param discount new value of discount
     */
    public void setDiscount(double discount)
    {
        this.discount = Redondeo.Redondear(discount,2);
    }

    public boolean isDelivered()
    {
        return delivered;
    }

    public void setDelivered(boolean delivered)
    {
        this.delivered = delivered;
    }

    public String getDiscountType()
    {
        return discountType;
    }

    public void setDiscountType(String discountType)
    {
        this.discountType = discountType;
    }
    
    
}
